home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Language/OS - Multiplatform Resource Library
/
LANGUAGE OS.iso
/
pcr
/
pcr4_4.lha
/
DIST
/
gc
/
GCptr_test.c
< prev
next >
Wrap
C/C++ Source or Header
|
1990-11-30
|
1KB
|
38 lines
# include <xr/GC.h>
# include <xr/GCPrivate.h>
/* If p is a valid pointer to an object, return a pointer to the */
/* beginning of that object. Otherwise return NIL. */
/* If szp is nonNIL, save the objects size in bytes in *szp. */
/* If ptrfreep is nonNIL, set *ptrfreep to 0 or 1 depending on */
/* whether or not the object is pointer free. */
/* An object may be considered valid even though it is about to */
/* be garbage collected because it was inaccessible during the */
/* last mark phase. A nonNIL result does guarantee that the */
/* object can be read without generating a fault. */
XR_Pointer XR_PtrTest(p, szp, ptrfreep)
struct obj * p; /* May be any 32 bit integer */
long * szp;
int * ptrfreep;
{
struct hblk * h;
int word_no;
long sz;
bool is_atomic;
# ifdef SEPARATE_HEADERS
register struct hblkhdr * hhdr;
# endif
if (!quicktest(p)) return(0);
# define CONTINUE return(0)
# define CONTINUE_M ;
# include "GCcheck_ptr.c"
# undef CONTINUE_M
# undef CONTINUE
if (szp) *szp = WORDS_TO_BYTES(sz);
if (ptrfreep) *ptrfreep = is_atomic;
return ((XR_Pointer)(((word *)h) + word_no));
}